package com.dmaximaging.fancypants {
	import flash.display.Sprite;
	import com.dmaximaging.fancypants.FancyItem;
		
	import flash.geom.Rectangle;
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.display.StageScaleMode;
	import flash.display.StageAlign;
	import flash.events.Event;
	
	public class FancyItems extends Sprite{
		public var items:Array;
		
		private var loadTrack_num:Number = 0;
		private var loadTarget_num:Number = 0;
		private var loaded_bool:Boolean = true;
		private var complete_fn:Function;
		
		public function FancyItems( items_xmllist:XMLList, complete_fn:Function ){
			items = new Array();
			this.complete_fn = complete_fn;
			loadTarget_num = items_xmllist.length();
			
			for( var i:Number = 0; i < items_xmllist.length(); i++ ){
				//trace( items_xmllist[i] );
				items.push( new FancyItem( items_xmllist[i], itemLoaded ) );
			}
			
			
		}
		
		public function itemLoaded(){
			trace( loadTarget_num + " and " + loadTrack_num );
			if( ++loadTrack_num == loadTarget_num ){
				loaded_bool = true;
				complete_fn();
			}
		}
		
		public function render():void {
			addChild( items[0] );
			addChild( items[1] );
			items[1].x = items[0].width + 10;
		}
	}
}